import requests
import re
from bs4 import BeautifulSoup

def read_book_message(html):
    html_read=requests.get(url=html)
    book_names=[]#书名
    writers=[]#作者
    publishes=[]#出版社
    time=[]#出版时间
    pages=[]#页数
    weight=[]#重量
    summary=[]#简介
    oldPrice=[]#原价格
    salePrice=[]#旧书价格
    savePrice=[]#节约价格
    soup=BeautifulSoup(html_read.text,'lxml')
    bookmessage=soup.findAll(class_='bi')
    return bookmessage

def main():
    url='http://www.youlu.net/classify/2-0101-4135-1.html'
    f=open('bookmessage.txt','w',encoding='utf-8')
    # f.write(str(read_book_message(url)))
    # for i in read_book_message(url):
    #     f.write(str(i))
    # f.close()
    # print(read_book_message(url))
    txt=read_book_message(url)
    for i in txt:
        # print('第一个元素')
        # print(i.contents)
        print(i)
    # print(a)
    # print(a.__len__())

if __name__ == '__main__':
    main()
